<?php

namespace app\admin\model\carbon\journalism;

use think\Model;


class Info extends Model
{





    // 表名
    protected $name = 'carbon_journalism_info';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text',
        'is_original_text',
        'create_time_text',
        'update_time_text'
    ];



    public function getTypeList()
    {
        return ['1' => __('热点咨询'), '2' => __('形式政策')];
    }

    public function getIsOriginalList()
    {
        return ['0' => __('否'), '1' => __('是')];
    }

    public function getLevelList()
    {
        return ['1' => __('普通'), '2' => __('重要')];
    }


    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getUpdateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsOriginalTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_original']) ? $data['is_original'] : '');
        $list = $this->getIsOriginalList();
        return isset($list[$value]) ? $list[$value] : '';
    }
}
